//
//  HomePageTwoCollectionViewCell.m
//  B_WatchHome
//
//  Created by dllo on 15/12/22.
//  Copyright © 2015年 DHF. All rights reserved.
//

#import "HomePageTwoCollectionViewCell.h"
#import <UIImageView+WebCache.h>
#import <Masonry.h>

@implementation HomePageTwoCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews
{
    self.backImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.backImageView];
    [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.right.mas_equalTo(0);
    }];
    
    self.headLabel = [[UILabel alloc] init];
//    self.headLabel.textColor = [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:0.9];
    self.headLabel.font = [UIFont boldSystemFontOfSize:13];
    [self.contentView addSubview:self.headLabel];
    [self.headLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-20);
        make.top.mas_equalTo(130);
        
    }];
    
    self.footLabel = [[UILabel alloc] init];
    self.footLabel.font = [UIFont boldSystemFontOfSize:10];
    [self.contentView addSubview:self.footLabel];
    [self.footLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-20);
        make.top.equalTo(self.headLabel.mas_bottom).offset(10);
        
    }];
    
}

- (void)setModel:(HomePageModel *)model
{
    if (_model != model) {
        _model = model;
    }
    
    self.headLabel.text = self.model.title;
    self.footLabel.text = self.model.pubdate;
    NSURL *url = [NSURL URLWithString:self.model.cover_landscape];
    
    [self.backImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@""]];
    
}




@end
